package com.zbkj.admin.controller.platform;

import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.MonitorOrderSaveRequest;
import com.zbkj.common.request.MonitorOrderSearchRequest;
import com.zbkj.common.response.MonitorOrderDetailResponse;
import com.zbkj.common.response.MonitorOrderPageDataResponse;
import com.zbkj.common.result.CommonResult;
import com.zbkj.common.request.PageParamRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import com.zbkj.service.service.MonitorOrderService;
import com.zbkj.common.model.order.MonitorOrder;


/**
 * 监控订单管理 前端控制器
 */
@Slf4j
@RestController
@RequestMapping("api/admin/platform/monitor/order")
@Api(tags = "监控订单管理", description = "商户入驻充值监控订单表") //配合swagger使用

public class PlatformMonitorOrderController {

    @Autowired
    private MonitorOrderService monitorOrderService;

    /**
     * 分页显示监控订单表
     *
     * @param request          搜索条件
     * @param pageParamRequest 分页参数
     * @author dazongzi
     * @since 2025-06-26
     */
    //@PreAuthorize("hasAuthority('platform:activitystyle:list')")
    @ApiOperation(value = "分页列表") //配合swagger使用
    @RequestMapping(value = "/list", method = RequestMethod.GET)
    public CommonResult<CommonPage<MonitorOrderPageDataResponse>> getList(@Validated MonitorOrderSearchRequest request,
                                                                          @ModelAttribute PageParamRequest pageParamRequest) {
        CommonPage<MonitorOrderPageDataResponse> monitorOrderCommonPage = CommonPage.restPage(monitorOrderService.getList(request, pageParamRequest));
        return CommonResult.success(monitorOrderCommonPage);
    }

    /**
     * 删除监控订单表
     * @param id Integer
     * @author dazongzi
     * @since 2025-06-26
     */
    @ApiOperation(value = "删除")
    @RequestMapping(value = "/delete", method = RequestMethod.GET)
    public CommonResult<String> delete(@RequestParam(value = "id") Integer id) {
        if (monitorOrderService.deleteById(id)) {
            return CommonResult.success();
        } else {
            return CommonResult.failed();
        }
    }

    /**
     * 查询监控订单表信息
     * @param id Integer
     * @author dazongzi
     * @since 2025-06-26
     */
    @ApiOperation(value = "详情")
    @RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
    public CommonResult<MonitorOrderDetailResponse> info(@PathVariable Integer id) {
        return CommonResult.success(monitorOrderService.getDetailById(id));
    }

}



